﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using GeneralDFS.Common.Network;
using GeneralDFS.Interface.Agent;
using NIF.MobileActors.Core;
using NIF.MobileActors.Hosts;
using GeneralDFS.DataEntity.Config;
using GeneralDFS.Client;

namespace AgentTest
{
    class Program
    {
        static void Main(string[] args)
        {
            RemotingHost.RegisterLocal(IPHelper.GetLocalIP("network"),8820);

            ActorProxy<IEntry> localActor = RemotingHost.LocalFacade.CreateLocalActor<IEntry>(typeof(SearchNodesActor));
            SearchNodesActor act = localActor.GetActor() as SearchNodesActor;
            Client client = new Client();
            Queue<IPEndPoint> hosts=new Queue<IPEndPoint>();
            foreach (NameNodeConfig nameNodeConfig in client.GetConfig().NameNodeConfigs)
            {
                var endPoint = new IPEndPoint(IPAddress.Parse(nameNodeConfig.Ip), nameNodeConfig.AgentRpcPort);
                hosts.Enqueue(endPoint);
            }

            act.Hosts = hosts;
            act.LocalHost = new IPEndPoint(IPAddress.Parse(IPHelper.GetLocalIP("network")), 8820);
            localActor.Post(h=>h.Excute());
            /*
            ActorProxy<IHello> proxy = RemotingHost.LocalFacade.GetActorProxy<IHello>(localActor.ID);
            if (proxy != null)
            {
                proxy.Post(h => h.Excute());
            }
            */
            Console.ReadKey();
        }
    }
}
